﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Conference.Command;
using Conference.Command.Command;
using Conference.Common;
using Conference.Common.Log;
using ConferenceWebApi.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ConferenceWebApi.Controllers
{
    /// <summary>
    /// 客户
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class CustomerController : ControllerBase
    {

        private readonly ICommandService _commandService;
        private readonly ILoggerHelper _loggerHelper;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="commandService"></param>
        /// <param name="loggerHelper"></param>
        public CustomerController(ICommandService commandService, ILoggerHelper loggerHelper)
        {
            _commandService = commandService;
            _loggerHelper = loggerHelper;
        }

        /// <summary>
        /// 创建客户
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseResult<string>> CreateCustomer([FromBody] CreateCustomerDto input)
        {
            var createCustomerCommand = new CreateCustomerCommand(input.CustomerName,input.CustomerAge,input.CustomerPhone,input.CustomerAddress);
            await _commandService.SendCommandAsync(createCustomerCommand);
            var result = new ResponseResult<string>
            {
                IsSucceed = true,
                Result = "创建客户成功！"
            };
            return result;
        }
    }
}